<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>

	<link rel="stylesheet" type="text/css" href="/static/lib/datatables/1.10.15/jquery.dataTables.css">
	<div th:include="admin/common :: head"></div>
	<!--[if lt IE 9]>
	<script type="text/javascript" src="/static/lib/html5shiv.js"></script>
	<script type="text/javascript" src="/static/lib/respond.min.js"></script>
	<![endif]-->

	<style type="text/css">
		.type{
			position:absolute;
			top:144px;
			left:166px;
			height:22px;
			width:90px;
			border:1px solid lightgray;
			z-index: 10;
		}

		th {
			text-align: center;
		}

		.table td {
			text-align: center;
		}
	</style>
	<title>单选题管理</title>
</head>

<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>问题管理
	<span class="c-gray en">&gt;</span> 简答题题管理
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px"
	   href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i>
	</a>
</nav>
<!--<div class="text-c">
</div>-->
<div class="cl pd-5 bg-1 bk-gray mt-20">
	<!--<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>-->

	<span class="l">
		<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
		<i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
		<a  class="btn btn-primary radius" th:href="@{/admin/question/questionAddPage}">
            <i class="Hui-iconfont">&#xe600;</i> 添加题目</a>
	<select class="type">
	<option value="1">计算机类</option>
	<option value="2">经济管理类</option>
	<option value="3">医学类</option>
	<option value="4">农学类</option>
	<option value="5">法学类</option>
	</select>
	</span>
	<span class="r" >共有数据：<div style="display:inline;line-height:31px" th:text="${essayQuestionList.size()} ">条</div></span>
</div>


<div class="page-container">

	<div class="mt-20">
		<table id="sheetList" class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
			<tr class="text-c">
				<th width="25"><input type="checkbox" name="" value=""></th>
				<th width="80">ID</th>
				<th width="80">详细信息</th>
				<th>描述</th>
				<th>选项</th>
				<th width="80">类型</th>
				<!-- <th width="70">状态</th> -->
				<th width="80">操作</th>
			</tr>
			</thead>
			<tbody>
			<tr  th:each="essayQuestion,essayQuestionList : ${essayQuestionList}" >
				<td><input type="checkbox" th:value="${essayQuestion.questionId}"  name=""></td>
				<td th:text="${essayQuestion.questionId}"></td>
				<td><span class="label label-success radius">
					<a style="text-decoration:none" class="ml-5"
					   th:onclick="|question_edit('查看题目','/admin/question/questionDetail/${essayQuestion.questionId }','${essayQuestion.questionId }')|"
					   href="javascript:;" title="查看题目">查看题目</a></span>
				</td>
				<td th:text="${essayQuestion.questionDesc}"></td>
				<th th:text="${essayQuestion.choice}"></th>
				<th th:text= "${essayQuestion?.courseType?.name}" ></th>

				<td class="td-manage">
					<a style="text-decoration:none" onClick="member_stop(this,'10001')" href="javascript:;" title="停用">
						<i class="Hui-iconfont">&#xe631;</i></a>
					<a title="编辑"  th:onclick="|javascript:question_edit('编辑','/admin/question/questionEditPage/${essayQuestion.questionId }','4','','510')|"
					   class="ml-5" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6df;</i></a>
					<a title="删除" href="javascript:;" th:onclick="|javascript:question_del(this,'${essayQuestion.questionId }')|"
					   class="ml-5" style="text-decoration:none">
						<i class="Hui-iconfont">&#xe6e2;</i></a>
				</td>

			</tr>
			</tbody>
		</table>
	</div>

</div>




<footer th:include="admin/common :: footer"></footer>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/datatables/1.10.15/jquery.dataTables.js"></script>
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>

<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting":
                [
                    [
                        1,"desc"
                    ]
                ],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable":false,"aTargets":[0,2,5]}// 制定列不参与排序
            ]
        });
        //复选框类型查询
        $('.type').change(function(){
            $.ajax({
                url: 'admin/question/essayQuestionList',
                data: 'examType=' + $('.type').val(),
                type: 'get',
                success: function(data){
                    $('#sheetList').html(data);
                },
                error: function(){
                    alert('网络出错');
                }
            })
        })

    });
    /*用户-添加*/
    function member_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*用户-查看*/
    function member_show(title,url,id,w,h){
        layer_show(title,url,w,h);

    }

    /*用户-编辑*/
    function question_edit(title,url,id,w,h){
        layer_show(title,url,w,h);
    }


    /*用户-删除*/
    function question_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: "POST",
                url: "/admin/question/questionDelete",
                data: {
                    questionId:id,
                },
                success: function(data){
                    //var data = eval('(' + data + ')');
                    if (data.code === 200){
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!',{icon:1,time:1000});
                        /* 不需要重新请求链接 */
                        /* location.href="${pageContext.request.contextPath}/teacher/teacherList" */
                        /*reloadTable();*/
                        location.replace(location.href);
                    }else{
                        alert("发生错误!请重新操作");
                    }
                }
            });
        });
    }
</script>
</body>
</html>